/**
 * @description: 不好分类的其他工具方法
 * @author: Ruan Jiazhen
 * @date: 2024-03-19 16:29:49
 **/

/**
 * @description: 获取设备安全区相关信息，并返回包含css对象的style字符串，且--safe-area-inset-bottom至少为12px
 */
export const getSafeArea = () => {
  const { safeArea, screenHeight, screenWidth } = wx.getSystemInfoSync();
  const { top, bottom, left, right, width, height } = safeArea;
  const style = `
  --safe-area-inset-top: ${top}px;
  --safe-area-inset-bottom: ${Math.max(screenHeight - bottom, 12)}px;
  --safe-area-inset-left: ${left}px;
  --safe-area-inset-right: ${screenWidth - right}px;
  --safe-area-inset-width: ${width}px;
  --safe-area-inset-height: ${height}px;
  `;
  return {
    style,
    top,
    bottom,
    left,
    right,
    width,
    height,
  };
};
